<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>修改密码</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no">
    <meta name="renderer" content="webkit" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="renderer" content="webkit|ie-comp|ie-stand" />
    <link rel="shortcut icon" href="/favicon.ico" type="/image/x-icon">
    <link rel="apple-touch-icon-precomposed" href="">
    <link rel="stylesheet" href="../source/src/css/main.css"/>
    <script src="../source/src/js/common.js"></script>

</head>
<body>
    <!-- 登录 -->
    <img src="../source/img/login/login_bg.jpg" alt="login_bg.jpg" class="login-bg">
    <div class="reset-pwd pubForm-box">
        <div class="hd">
            <div class="logo">
                <img src="../source/img/public/logo.png" alt="logo.png">
            </div>
            <div class="company_name">
                <img src="../source/img/public/company_name.png" alt="company_name.png">
            </div>
        </div>
        <div class="bd">
            <ul>
                <li class="pwd-box clearfix">
                    <div class="label fl">
                        新密码：
                    </div>
                    <div class="v fl">
                        <input type="password" name="" id="password" class="inp"/>
                    </div>
                </li>
                <li class="pwd-box clearfix">
                    <div class="label fl">
                        确认密码：
                    </div>
                    <div class="v fl">
                        <input type="password" name="" id="rePassword" class="inp"/>
                    </div>
                </li>
                <li class="error-tip animated">

                </li>
            </ul>
            <div class="btn-box">
                <input type="submit" value="确认修改" id="reset-pwd-btn" class="reset-pwd-btn">
            </div>
        </div>
    </div>
    <!-- /登录 -->

    <!--底部菜单-->
    <div class="pub-nav">
        <ul>
            <li>
                <a href="../index.html">
                    <div class="index pic"></div>
                    <div class="txt">首页</div>
                </a>
            </li>
            <li>
                <a href="./shop_cart.html?v=210818">
                    <div class="shopCart pic"></div>
                    <div class="txt">购物车</div>
                </a>
            </li>
            <li class="on">
                <a href="./me.html">
                    <div class="me pic"></div>
                    <div class="txt">我</div>
                </a>
            </li>
        </ul>
    </div>
    <!--/底部菜单-->

    <script src="../source/plugin/zepto.min.js"></script>
    <script src="../source/src/js/common.js"></script>
    <script>
        $(function(){
            function checkResetPwd(pwd,rePwd){
                var  pwd=pwd,
                        rePwd=rePwd,
                        errorTxt='';
                if ($.trim(pwd)=="") {
                    errorTxt="请输入新密码！";
                }else if($.trim(rePwd)==""){
                    errorTxt="请输入确认密码！";
                }else if(pwd!=rePwd){
                    errorTxt="两次密码输入不一致！";
                }
                return errorTxt !="" ? errorTxt : true;
            }

            $('#reset-pwd-btn').on('click',function(){
                var pwd=$('#password').val() || "",
                        rePwd=$('#rePassword').val() || "",
                        errorMsg = checkResetPwd(pwd,rePwd);
                if(errorMsg===true) {
                    $('.error-tip').html("").hide();
                    var inJson ={
                        "username":decodeURIComponent(getCookie('username')),
                        "pwd":$('#rePassword').val(),
                        "key":user.key,
                        "account":user.account
                    };

                    $.ajax({
                        url:apiUrl+'/UpdLogin',
                        type:'GET',
                        data:{"json":JSON.stringify(inJson)},
                        //dataType :'jsonp',
                        success:function(datas){
                            if(datas.Success==true){
                                show_error_tip({str:"密码修改成功"});
                            }else{
                                show_error_tip({str:"密码修改失败"});
                            }
                        },
                        error:function(datas){
                            console.log(datas.msg)
                        }
                    });
                }else{
                    $('.error-tip').html(errorMsg).show().addClass('shake').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){
                        $(this).removeClass('shake');
                    });
                }
            })
        })
    </script>
</body>
</html>